﻿using Core.UI;
using Core.UI.UISub;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;

namespace Game.UI.Example
{
    public class PlayerHUD : UIHUDBase
    {
        public PlayerStatusBar hpBar;
        public PlayerStatusBar ppBar;
        public Button settingBtn;

        protected override void Awake()
        {
            base.Awake();
            
            settingBtn.onClick.AddListener(OnShowSettingInGame);
        }

        private void Start()
        {
            UIManager.Ins.ClearAllUI();
        }

        private void OnShowSettingInGame()
        {
            UIManager.Ins.ShowUI(UIWindowName.MenuSettingWindow, ui =>
            {
                MenuSettingWindow menuSettingWindow = (MenuSettingWindow)ui;
                menuSettingWindow.SetSettingType(MenuSettingWindow.SettingType.InGaming);
            }).Forget();
        }

        protected override void Update()
        {
            base.Update();
            
            hpBar.SetValue(Mathf.Sin(Time.time), 1);
            ppBar.SetValue(Mathf.Sin(Time.time), 1);
        }
    }
}